home *** CD-ROM | disk | FTP | other *** search
/ Enter 2010 January / ENTER_2010_01.iso / Programy / Gry / Base_Invaders_ / BaseInvadersSetup1.3.exe / {app} / Scripts / MainMenu.lua < prev    next >
Encoding:
Text File  |  2007-01-25  |  5.2 KB  |  246 lines

  1.     
  2.  
  3. function PlayIntroMenu()
  4.     -- Close main window
  5.     if( ( HUD == nil or HUD.GetCurrentWindow() == "" ) and ( GameState ~= InLevel ) ) then
  6.         PlayIntro()
  7.     end
  8. end
  9.  
  10. -- Quick Start Function:
  11. function QuickStart()
  12.     StartLevel( "Scripts/QuickStartStartup.lua" );
  13. end
  14.  
  15. function StartTutorial()
  16.     StartLevel( "Scripts/Tutorial.lua" );     
  17. end
  18.  
  19. function StartCampaign1()
  20.     StartLevelCampaign( 1 );
  21. end
  22. function StartCampaign2()
  23.     StartLevelCampaign( 2 );
  24. end
  25. function StartCampaign3()
  26.     StartLevelCampaign( 3 );
  27. end
  28. function StartCampaign4()
  29.     StartLevelCampaign( 4 );
  30. end
  31. function StartCampaign5()
  32.     StartLevelCampaign( 5 );
  33. end
  34. function StartCampaign6()
  35.     StartLevelCampaign( 6 );
  36. end
  37. function StartCampaign7()
  38.     StartLevelCampaign( 7 );
  39. end
  40. function StartCampaign8()
  41.     StartLevelCampaign( 8 );
  42. end
  43. function StartCampaign9()
  44.     StartLevelCampaign( 9 );
  45. end
  46. function StartCampaign10()
  47.     StartLevelCampaign( 10 );
  48. end
  49.  
  50.  
  51. function NextCampaignLevel()
  52.  
  53.     if( InCampaign ) then
  54.         -- Start the next level of the game:
  55.         Obj = G.GetCogName( "Camera" );        
  56.         Obj.Destroy();
  57.         
  58.         G.DestroyGroup("camera");
  59.         G.Create( "Data/BasicCamera.xml" );
  60.         MainMenu.CloseWindow( "GameOverWindow" );
  61.         
  62.         if( not( CurrentLevel == MaxLevelNum ) and GameState == Victory ) then
  63.             CurrentLevel = CurrentLevel + 1 
  64.         end
  65.         
  66.         StartLevelCampaign( CurrentLevel )
  67.     end
  68. end
  69.  
  70. function ChooseLevel( filename, number )
  71.     CurrentLevel = number + 1
  72.     StartLevelCampaign( CurrentLevel )
  73. end
  74.  
  75.  
  76. function StartPhysicsMode()
  77.     G.ActivateBackground( -1 );
  78.     MainMenu.CloseWindow( "LevelChoiceWindow" );
  79.     G.LogicCreateLevel("Scripts/PhysicsStartup.lua");     
  80. end
  81.  
  82. function ExitGame()
  83.     G.Exit();
  84. end
  85.  
  86. function SetMusicFolder( name )
  87.     G.ChangeMusicFolder( folderName );
  88.     G.PlayRandomSong();
  89. end    
  90.  
  91. function PauseMusic( pause )
  92.     if( pause ) then
  93.         G.PauseMusic();
  94.     else
  95.         G.PlayMusic();
  96.     end
  97. end        
  98.     
  99. EscPauseStatus = true
  100. EscCursorStatus = true
  101. function OpenInGame()
  102.     
  103.     EscPauseStatus = G.IsPaused()
  104.     EscCursorStatus = G.IsCursorActive()
  105.     
  106.     G.OnlyShowMouseOnGui( false );
  107.  
  108.     -- Tutorial stuff
  109.     KillTextPopup()
  110.  
  111.     MainMenu.OpenWindow( "InGameWindow", false );
  112.     G.SetCursorActive( false );
  113.     G.SetPause( true );        
  114. end
  115.  
  116. function ResumeGame()
  117.     MainMenu.CloseWindow( "InGameWindow" );
  118.     G.SetPause( EscPauseStatus );    
  119.     G.SetCursorActive( EscCursorStatus );
  120.     
  121.     G.OnlyShowMouseOnGui( true );
  122. end
  123.     
  124. function ExitInGame()
  125.     G.SetGameState( QuitLevel )
  126. end
  127.         
  128. function EnableInvaderSpeech( value )
  129.     G.InvaderSpeech( value )
  130. end
  131.  
  132.  
  133. function OpenBonus()
  134.     -- DisableTraitor();
  135.     MainMenu.OpenWindow( "BonusWindow", true );
  136. end
  137.  
  138. function OpenLevelChoice()
  139.     -- DisableTraitor();
  140.     MainMenu.OpenWindow( "LevelChoiceWindow", true );
  141. end
  142.  
  143. function ExitLevelChoice()
  144.     MainMenu.OpenWindow( "StartWindow" , true );
  145. end
  146.             
  147. function ExitInvaderViewer()
  148.     MainMenu.OpenWindow( "BonusWindow", true );
  149. end
  150.  
  151. function OpenCredits()
  152.     MainMenu.OpenWindow( "CreditsWindow", true );
  153. end
  154.  
  155.  
  156. function OpenControls()
  157.     MainMenu.OpenWindow( "ControlsWindow", true );
  158. end
  159.  
  160. function ExitControls()
  161.     MainMenu.OpenWindow( "BonusWindow", true );
  162. end
  163.  
  164.  
  165. function OpenInvaderViewer()
  166.     MainMenu.OpenWindow( "InvaderViewerWindow", true );
  167. end
  168.  
  169.  
  170. function ExitCredits()
  171.     MainMenu.OpenWindow( "BonusWindow" , true );
  172. end
  173.  
  174. function ExitBonus()
  175.     if( LevelActive  ) then
  176.         MainMenu.OpenWindow( "InGameWindow" , true );
  177.     else
  178.         MainMenu.OpenWindow( "StartWindow" , true );
  179.     end
  180. end
  181.  
  182.  
  183.  
  184. function HideGameOver()
  185.  
  186.     InCampaign = false;
  187.  
  188.     MainMenu.OpenWindow( "StartWindow", true);
  189.     G.ActivateBackground( 0 );
  190.     Obj = G.GetCogName( "Camera" );        
  191.     Obj.Destroy();
  192.     
  193.     G.DestroyGroup("camera");
  194.     G.Create( "Data/BasicCamera.xml" );
  195.  
  196. end
  197.     
  198. function GameOverScreen( text )    
  199.     G.UpdateGameOverStats();                
  200.     MainMenu.Message( "GameOverText", "SetText", text);    
  201.     if( GameState == Victory ) then
  202.         G.ActivateBackground( 1 );
  203.     else
  204.         G.ActivateBackground( 2 );
  205.     end
  206. end
  207.  
  208. dofile( "Scripts/GameSettings.lua" );
  209.  
  210.  
  211. LevelPics = {}
  212. LevelPics.Tutorial  = "Textures/LevelPics/Tutorial.png"
  213. LevelPics.Challenge = "Textures/LevelPics/Challenge.png" 
  214. LevelPics.Campaign1 = "Textures/LevelPics/Campaign1.png"
  215. LevelPics.Campaign2 = "Textures/LevelPics/Campaign2.png"
  216. LevelPics.Campaign3 = "Textures/LevelPics/Campaign3.png"
  217. LevelPics.Campaign4 = "Textures/LevelPics/Campaign4.png"
  218. LevelPics.Campaign5 = "Textures/LevelPics/Campaign5.png"
  219. LevelPics.Campaign6 = "Textures/LevelPics/Campaign6.png"
  220. LevelPics.Campaign7 = "Textures/LevelPics/Campaign7.png"
  221. LevelPics.Campaign8 = "Textures/LevelPics/Campaign8.png"
  222. LevelPics.Campaign9 = "Textures/LevelPics/Campaign9.png"
  223. LevelPics.Campaign10 = "Textures/LevelPics/Campaign10.png"
  224.  
  225. waitTime = 30
  226.  
  227. function LevelChoiceUpdate()
  228.     if( LevelPics[ GuiObjectOver ] ~= nil ) then
  229.         MainMenu.Message( "LevelImageBox", "SetImage",     LevelPics[ GuiObjectOver ] );
  230.     end
  231.     
  232.     -- Wait 30 Seconds on mainmenu for replay. 
  233.     if( MainMenu.GetCurrentWindow() == "StartWindow" ) then
  234.         waitTime =  waitTime - GameTimeDiff
  235.         if( waitTime <= 0 ) then
  236.             waitTime = 30
  237.             PlayIntroMenu()
  238.         end
  239.     elseif( true ) then
  240.         waitTime = 30
  241.     end
  242. end
  243.  
  244. GMain["LevelChoiceUpdate"] = LevelChoiceUpdate
  245.  
  246.